/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elevatronic.controllers;

import elevatronic.models.Building;
import java.util.List;

/**
 *
 * @author Exosta
 */
public class Sensors {
    
    private Building building;

    private ArtificialElevator elevator;

    public Sensors(Building building, ArtificialElevator elevator) {
        this.building = building;
        this.elevator = elevator;
    }
    
    public int[] sensoring() {
        int sensors[] = {countUpButtonsFromDown(), countDownButtonsFromUp(), countUpButtonsFromDown(), countUpButtonsFromUp()};
        return sensors;
    }
    
    public void targettedFloors() {

    }
    
    public int countUpButtonsFromUp() {
        int counted = 0;
        for (int i = this.elevator.getElevator().getCurrentFloor(); i < this.building.getFloors().size(); i++) {
            if(this.building.getFloors().get(i).getButtonUp().isPushed())
                counted++;
        }
        return counted;
    }
    
    public int countUpButtonsFromDown() {
        int counted = 0;
        for (int i = this.elevator.getElevator().getCurrentFloor(); i <= 0 ; i--) {
            if(this.building.getFloors().get(i).getButtonUp().isPushed())
                counted++;
        }
        return counted;
    }
    
    public int countDownButtonsFromUp() {
        int counted = 0;
        for (int i = this.elevator.getElevator().getCurrentFloor(); i < this.building.getFloors().size(); i++) {
            if(this.building.getFloors().get(i).getButtonDown().isPushed())
                counted++;
        }
        return counted;
    }
    
    public int countDownButtonsFromDown() {
        int counted = 0;
        for (int i = this.elevator.getElevator().getCurrentFloor(); i <= 0 ; i--) {
            if(this.building.getFloors().get(i).getButtonDown().isPushed())
                counted++;
        }
        return counted;
    }
}
